package com.wugui.datax.admin.controller;

import static com.wugui.datatx.core.util.Constants.STRING_BLANK;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import com.baomidou.mybatisplus.extension.api.ApiController;
import com.wugui.datax.admin.util.JwtTokenUtils;

/**
 * base controller
 */
public class BaseController extends ApiController {

	public Integer getCurrentUserId(HttpServletRequest request) {
		Enumeration<String> auth = request.getHeaders(JwtTokenUtils.TOKEN_HEADER);
		String token = auth.nextElement().replace(JwtTokenUtils.TOKEN_PREFIX, STRING_BLANK);
		return JwtTokenUtils.getUserId(token);
	}
}